package com.hw01.controller;

import com.hw01.controller.vo.ResultVO;
import com.hw01.entity.User;
import com.hw01.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName UserController
 * @Description TODO
 * @Author Kx
 * @Date 2025/5/13 8:32
 * @Version 1.0
 */
// 标识为控制器并解析JSON格式数据
@RestController
public class UserController extends BaseController{

    // 业务层对象
    private final UserService service;

    public UserController(UserService service) {
        this.service = service;
    }

    /**
     * @author: kx
     * @date: 2025/5/13 8:33
     * @return java.lang.String
     * @description: 查询用户所有信息
    */
    @GetMapping("/finAllUser")
    public ResultVO<List<User>> findAllUser() {
        // 获取所有用户信息
        List<User> allUser = service.findAllUser();
        // 返回结果
        return success(allUser);
    }

    /**
     * @author: kx
     * @date: 2025/5/14 14:58
     * @return com.hw01.controller.vo.ResultVO<java.lang.String>
     * @description: 根据编号查询用户信息
    */
    @GetMapping("/findById")
    public ResultVO<String> findById() {
        return success("huang");
    }
}
